/*
 * @Author: 张笑天
 * @Date: 2018-03-07 17:13:20
 * @Last Modified by: Theoton
 * @Last Modified time: 2018-07-28 13:36:55
 */
import React from 'react';
import ReactDOM from 'react-dom';

import { createHashHistory } from 'History';

import { Router, Route, useRouterHistory, IndexRedirect } from 'react-router';

import { syncHistoryWithStore, RouterStore } from 'mobx-react-router';

import { Provider } from 'mobx-react';

import { WeaLocaleProvider } from 'ecCom';

import Email from 'weaEmail';

import PrintEmail from './components/PrintEmail';

import '../portal4theme/components/theme/ecology9/style/index';

const getLocaleLabel = WeaLocaleProvider.getLocaleLabel.bind(this, 'email');

const routing = new RouterStore();

const allStore = {
  routing,
  ...Email.store,
};

const browserHistory = useRouterHistory(createHashHistory)({
  queryKey: '_key',
  basename: '/',
});

const history = syncHistoryWithStore(browserHistory, allStore.routing);

const Home = props => props.children;

const Root = () => (
  <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@i0kg30`} {...allStore}>
    <Router ecId={`${this && this.props && this.props.ecId || ''}_Router@qv011k`} history={history}>
      <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@9ktycg`} name="root" breadcrumbName="根路由" path="/" component={Home} onEnter={getLocaleLabel}>
        <IndexRedirect ecId={`${this && this.props && this.props.ecId || ''}_IndexRedirect@0cy180`} to="main/email/inbox?folderid=0&receivemail=true&receivemailid=0" />
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@jxh03z`} name="main" breadcrumbName="入口" path="/main" component={Home}>
          { Email.Route }
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@0cpp3e`} name="print" breadcrumbName="打印页面" path="printemail/printemail" component={PrintEmail} />
        </Route>
      </Route>
    </Router>
  </Provider>
);

ReactDOM.render(<Root ecId={`${this && this.props && this.props.ecId || ''}_Root@lnd3e2`} />, document.getElementById('container'));
